const app = getApp()
const request = require('../../utils/https.js')
import util from '../../utils/util.js';
var userId;
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    const that = this;
    userId = wx.getStorageSync('userId');
    let getMoney = options.getMoney;
    let actualMoney = options.actualMoney;
    let states = options.states; // states 0 - 待审核 1 - 审核成功 2 - 审核未成功3 - 提现成功 7 - 取消提现;
    let cashId = options.cashId;
    let directly = options.directly; //直接提现进入
    //如果没有directly 证明是 刚完成提现 展示位提交申请 不用发请求
    console.log('directly===>', directly)
    if (!directly) {
      console.log('没有directly')
      that.setData({
        getMoney: getMoney,
        realMoney: actualMoney,
        cashId: cashId,
        type: 0
      })
    } else {
      console.log('有directly')
      request._get(getApp().Api_url + 'profit/cashInfo', {
        userId: userId,
        cashId: cashId,
      }, function(res) {
        if (res.data.errCode == '200') {
          console.log('提现状态展示==>', res.data.data.kinds)
          that.setData({
            //type: res.data.data.kinds,// 0 已提交 2未通过 3已到账
            cashId: res.data.data.cashId,
            getMoney: res.data.data.applyMoney,
            realMoney: res.data.data.realMoney,
            type: res.data.data.states, //0-待审核 1-审核成功 2-审核未成功3-提现成功 
            reason:res.data.data.reason
          })


        }
      }, function() {})
    }


  },
  goShopping() {
    const that = this;
    request._get(getApp().Api_url + 'profit/read', {
      cashId: that.data.cashId
    }, function(res) {
      if (res.data.errCode == 200) {
        console.log('知道了==>', res.data.data)
        wx.navigateBack({
          delta: 1
        })


      }
    }, function() {})
  },
  //自定义弹框
  onToast() {
    const that = this;
    that.setData({
      isHideToast: true
    })
  },
  shutToast() {
    const that = this;
    that.setData({
      isHideToast: false,
      isHideToast1: false
    })
  },
  //撤销提现询问
  onUndo() {
    const that = this;
    that.setData({
      isHideToast1: true
    })
  },
  //撤销提现
  goiDentity() {
    const that = this;
    request._get(getApp().Api_url + 'profit/cancel', {
      cashId: that.data.cashId,
      userId: userId
    }, function(res) {
      if (res.data.errCode == 200) {
        console.log('撤销提现成功==>', res.data.data)
        wx.navigateBack({
          delta: 1
        })
        wx.showToast({
          icon: 'none',
          title: '撤销提现成功',
        })

      }
    }, function() {})
  },
  goList(){
    wx.switchTab({
      url: '/pages/list/list'
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  }
})